function saveQRcode(data) {
  let that = this
  console.log(data);
  wx.request({
    url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx3069280b94304887&secret=ad4f3f496602aa8721342d437a045cf2',
    success: res => {
      let access_token = res.data.access_token
      wx.request({
        url: 'https://api.weixin.qq.com/wxa/getwxacode?access_token=' + access_token,
        method: 'POST',
        data: {
          path: 'pages/pay/exclusive-monthly/monthly?parkData={"parkName":' + data.id+ ',"id":'+ data.id+'}'
        },
        success: res => {
          var imgSrc = res.data;//base64编码
          var save = wx.getFileSystemManager();
          var number = Math.random();
          save.writeFile({
            filePath: wx.env.USER_DATA_PATH + '/' + data.id + '.png',
            data: imgSrc,
            encoding: 'base64',
            success: res => {
              wx.saveImageToPhotosAlbum({
                filePath: wx.env.USER_DATA_PATH + '/' + data.id + '.png',
                success: function (res) {
                  wx.showToast({
                    title: '保存成功',
                  })
                },
                fail: function (err) {
                  console.log(err)
                }
              })
              console.log(res)
            }, fail: err => {
              console.log(err)
            }
          })
        }
      })
    }
  })
}

module.exports = {
  saveQRcode
}